﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

/// <summary>
/// Summary description for DatabaseConnection
/// </summary>
public class DatabaseConnection
{
    string connectionString;
    SqlConnection connection;
    Account account;
	public DatabaseConnection()
	{
        connection = new SqlConnection("Data Source=.;Initial Catalog=MrMobileDB;Integrated Security=True");
        account = new Account();
	}
    public bool verifyAccount(string username, string password)
    {
        connection.Open();
        SqlCommand verifyCommand = new SqlCommand("exec "+account.verifyAccount+" '"+username+"','"+password+"'",connection);
        SqlDataReader Read = verifyCommand.ExecuteReader();
        if(Read.Read())
        {
            return true;
        }
        else
        {
            return false;
        }
        connection.Close();
    }

    public void insertAccount(string username, string password, string firstName, string lastName, string birthDate, string email, string Telephone, string country)
    {
        connection.Open();
        SqlCommand insertcommand = new SqlCommand("exec "+account.insertAccount+" '"+username+"','"+password+"','"+firstName+"','"+lastName+"','"+birthDate+"','"+email+"','"+Telephone+"','0','1','"+country+"'",connection);
        insertcommand.ExecuteNonQuery();
        connection.Close();
    }
}
